package Day01;

/**
 * @author feng
 * @Date 2021/9/24 9:28
 *  冒泡排序法，将字符串从小到大拍戏
 */
public class StringSort {
    public static void main(String[] args) {
        String[] str = {"China","USA","Russia","France","England"};

        for (int i = str.length-1; i >=0; i--) {
            for (int j = 0; j <i ; j++) {
                if (str[j].compareTo(str[j+1])>0){
                    String tmp = str[j];
                    str[j] = str[j+1];
                    str[j+1] = tmp;

                }

            }

        }
        for (String s:str) {
            System.out.println(s +" ");
        }

    }
}
